<%--
 *  File:    MonthAccountsSettle.jsp
 *  @Author: Vector Mao
 *  Date:    2002-4-24 13:14
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom-tag.tld" prefix="custom" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="scustom" %>

<%
  	//init param
  	HashMap userinfo = (HashMap)session.getAttribute("userinfo");
  	if (userinfo==null)
  	  userinfo = new HashMap();
  	Category cat = Category.getInstance("jsp.MonthAccountsSettle");
	  String privilegeCode = "40501";
  	String strModuleName = "FIM";
  	String strClassType = "";
  	String strTableName = "ovaccountingperiod";
%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<html>
<head>
<title>MonthAccountsSettle</title>
<PageFlow:CheckPageFlow pageName="monthaccountssettle"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../css/<%= strLanguageCode %>/script.js">
</script>
<script language="JavaScript" src="../js/FuncLib.js">
</script>
<%--------------------------------------  output variant from pageflow   --%>
<%
	Vector accountingperiods = (Vector)pageContext.getAttribute("accountingperiods");
	if(accountingperiods == null)
  	accountingperiods = new Vector();
%>
<script>
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  editform.action = "MonthAccountsSettle.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}
function clickIt(id, status)
{
  	cform.currentid.value = id;
  	cform.currentstatus.value = status;
}
function page_operate(operand)
{

	  if (operand=="trans")
	  {
         if (!confirm("<%= message.getMessageDesc("USERLOGINMGMT_SHUTEAI_FIRST")%>"))
         {
            return;
         }

	    if (<%=JspHelper.filterNull(accountingperiods.size())%>==0)
	    {
	      alert("<%= message.getMessageDesc("CAN_NOT_SETTLE") %>");
	      return;
	    }
	    if( !confirm("<%= message.getMessageDesc("SURE_TO_SETTLE") %>"+ cform.openperiod.value) )
        return;



      cform.action = "../gl/MonthEndCloseOff.jsp?<%= OvalTools.randomURL() %>";
//          cform.actionname.value = "settle";
      cform.target = "_self";
      isRunning = true;
      cform.submit();
	  }

}
function page_zctprofitloss(iaraptype)
{
    <%
    Vector allnoendrate = (Vector)pageContext.getAttribute("allnoendrate");
	if(allnoendrate == null)
  	allnoendrate = new Vector();
    if(allnoendrate.size()>0)
    {
    %>
    alert("<%= message.getMessageDesc("J_EXCHANGERATE_CAN_NOT_FOUND")%>");
    return;
    <%
    }
    %>
    cform.araptype.value=iaraptype;
    if(!confirm("<%= message.getMessageDesc("SURE_TO_ZCTPROFITLOSS")%>"))
    return;
    cform.actionname.value = "profitloss";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}

function page_unsettle()
{
    if(!confirm("<%= message.getMessageDesc("J_Sure_UNSETTLE")%>"))
    return;
    cform.actionname.value = "unsettleforlc";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}

function page_checkslip()
{
    if(!confirm("<%= message.getMessageDesc("SURE_TO_CHECKSLIP")%>"))
    return;
    self.location.href='CheckSlip.jsp?<%= OvalTools.randomURL() %>';
}
function page_saveaccount()
{
  if(!confirm('<%=message.getMessageDesc("ARE_YOU_SURE")%>' + '(<%=JspHelper.filterNull(userinfo.get("glaccountingyear"))%>-' + '<%=JspHelper.filterNull(userinfo.get("glaccountingperiod"))%>)')) return;
  cform.isaccountsave.value="N";
  cform.target="_self";
  cform.actionname.value="saveaccount";
  isRunning=true;
  cform.submit();
}

function reload()
{
  cform.action = "MonthAccountsSettle.jsp?<%= OvalTools.randomURL() %>";
  cform.target = "_self";
  isRunning = true;
  cform.submit();
}

</script>
<%@ include file="/inc/SummaryDivision.inc" %>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
	<form name="cform" method="post" action="../Dispatcher">
    <input type="hidden" name="pagename" value="monthaccountssettle">
    <input type="hidden" name="actionname">
    <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
    <input type="hidden" name="accperiodid" value="">
    <input type="hidden" name="orgid" value="<%=JspHelper.filterNull( userinfo.get("orgid"))%>">
    <input type="hidden" name="passlabel" value="<%=label.getLabelName("L_CheckPass",false)%>">
    <input type="hidden" name="notpasslabel" value="<%=label.getLabelName("L_CheckNotPass",false)%>">
    <input type="hidden" name="successlabel" value="<%=label.getLabelName("L_Success",false)%>">
    <input type="hidden" name="unsuccesslabel" value="<%=label.getLabelName("L_UnSuccess",false)%>">
     <input type="hidden" name="isaccountsave">
     <input type="hidden" name="checksuccessflag">
     <input type="hidden" name="araptype">
    <scustom:hidden property="checkelementtype"/>
    <%--------------------------------------  page location   --%>
	<%@ include file="/inc/PageLocation.inc" %>
	<%--------------------------------------  hidden form variant   --%>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
  <tr>
    <td class="summary_top" > </td>
  </tr>
<%
    int icketype=0;
    if(pageContext.getAttribute("checkelementtype")!=null){
        icketype = ((Integer)pageContext.getAttribute("checkelementtype")).intValue();
    }
    if(icketype==8){%>
 <tr>
    <td>
          <font color="red"><%=label.getLabelName("L_InsideLeger")+label.getLabelName("L_Colon")%>   </font>
          <scustom:select optionsName="allilbookset" optionValueKey="booksetid" optionInnerTextKey="booksetname"  property="booksetid" onchange="javascript:reload();" />
     </td>
</tr>
<%}else{%>
     <scustom:hidden property="booksetid" name="booksetinfo" />
<%}%>
  <tr>
    <td>
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
          <tr class="deepblue-left">
            <td class="title_center" width="30"><%= label.getLabelName("L_Sequence") %></td>
            <td class="title_center"           ><%= label.getLabelName("L_StartDate") %></td>
            <td class="title_center"           ><%= label.getLabelName("L_EndDate") %></td>
            <td class="title_center"           ><%= label.getLabelName("L_CloseDate") %></td>
            <td class="title_center" width="55"><%= label.getLabelName("L_Status") %></td>
          </tr>
          	<%
            	Integer nDefaultId = new Integer(-1);
            	Integer nDefaultStatus = new Integer(-1);
                String strPeriod = null;
              %>
          	<logic:iterate id="ps" collection="<%= accountingperiods %>" indexId="orderId">
          	<%
            	HashMap psMap = (HashMap)ps;
            	String strIsChecked = "";

            	if((orderId.intValue())%2 == 1)
            	{
              		strClassType = "td-listrom";
            	}else{
              		strClassType = "none";
            	}
            	if(orderId.intValue()==0)
            	{
              		strIsChecked = "Checked";
              		nDefaultId = (Integer)(psMap.get("accperiodid"));
              		nDefaultStatus = (Integer)(psMap.get("status"));
                }
                  if(
                          (strPeriod==null)
                          &&
                           (
                                 (((Integer)(psMap.get("status"))).intValue()==40)
                                  ||
                                 ((((Integer)(psMap.get("status"))).intValue()==39) && (icketype==1) )
                           )
                     )
                    strPeriod="("+(psMap.get("begindate")).toString()+ "--" + (psMap.get("enddate")).toString()+")";
               %>
          <tr   class="<%=JspHelper.filterNull( strClassType )%>">
            <td><%=JspHelper.filterNull( (orderId.intValue()+1) )%>&nbsp;</td>
            <td><scustom:write name="ps" property="begindate" dataType="date"  dataFormatName="dateformat"/>&nbsp;</td>
            <td><scustom:write name="ps" property="enddate" dataType="date"  dataFormatName="dateformat"/>&nbsp;</td>
            <td><scustom:write name="ps" property="closedate" dataType="date"  dataFormatName="dateformat"/>&nbsp;</td>
            <td><scustom:write name="ps" property="status" dictType="Status"/>&nbsp;</td>
          </tr>
        	</logic:iterate>
			    <input type="hidden" name="currentid" value="<%=JspHelper.filterNull( nDefaultId )%>">
			    <input type="hidden" name="currentstatus" value="<%=JspHelper.filterNull( nDefaultStatus )%>">
                <input type="hidden" name="openperiod" value="<%=JspHelper.filterNull( strPeriod )%>">
      </table>
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td class="summary_top"></td>
        </tr>
        <tr>
          <td class="td_center">
          <a onclick="page_operate('trans')"><custom:button type="1" label="L_Trans" imgsrc="trans.gif" border="0" style="width:60"/></a>
<%if(icketype==5){%>
          <a onclick="page_zctprofitloss(1)"><custom:button type="1" label="L_ARZCTProfitLoss" imgsrc="trans.gif" border="0" style="width:100"/></a>
          <a onclick="page_zctprofitloss(2)"><custom:button type="1" label="L_APZCTProfitLoss" imgsrc="trans.gif" border="0" style="width:100"/></a>
          <a onclick="page_checkslip()"><custom:button type="1" label="L_CheckSlip" imgsrc="trans.gif" border="0" style="width:80"/></a>
<%}else if(icketype==9){%>
          <a onclick="page_unsettle()"><custom:button type="1" label="L_MonthASU" imgsrc="trans.gif" border="0" style="width:80"/></a>
<%}%>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</form>
</body>
<%
  Vector vErrorCode=(Vector)session.getAttribute("errorcode");
  if(vErrorCode!=null && vErrorCode.size()>0)
  {
    for(int ij=0;ij<vErrorCode.size();ij++)
    {
      HashMap hmTmp=(HashMap)vErrorCode.get(ij);
      if(hmTmp==null)
        continue;
      else
      {
        String strmsg=OvalTools.replaceQuot(message.getMessageDesc(hmTmp,session));

%>
        <script>
          alert("<%=JspHelper.filterNull(strmsg)%>");
        </script>
<%
        break;
      }
    }
    session.removeAttribute("errorcode");
  }
%>
</html>


